package com.ruoyi.finance.controller;

import java.util.Date;
import java.util.List;
import java.io.IOException;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.finance.domain.EAccount;
import com.ruoyi.finance.service.IEAccountService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 账户信息Controller
 *
 * @author ruoyi
 * @date 2024-11-21
 */
@RestController
@RequestMapping("/account")
public class EAccountController extends BaseController
{
    @Autowired
    private IEAccountService eAccountService;

    /**
     * 查询账户信息列表
     */

    @RequiresPermissions("finance:account:list")
    @GetMapping("/list")
    public TableDataInfo list(EAccount eAccount)
    {
        startPage();
        List<EAccount> list = eAccountService.selectEAccountList(eAccount);
        return getDataTable(list);
    }


//    /**
//     * 导出账户信息列表
//     */
//    @RequiresPermissions("finance:account:export")
//    @Log(title = "账户信息", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, EAccount eAccount)
//    {
//        List<EAccount> list = eAccountService.selectEAccountList(eAccount);
//        ExcelUtil<EAccount> util = new ExcelUtil<EAccount>(EAccount.class);
//        util.exportExcel(response, list, "账户信息数据");
//    }

    /**
     * 获取账户信息详细信息
     */
    @RequiresPermissions("finance:account:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(eAccountService.selectEAccountById(id));
    }

    /**
     * 新增账户信息
     */
    @RequiresPermissions("finance:account:add")
    @Log(title = "账户信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EAccount eAccount)
    {
        return toAjax(eAccountService.insertEAccount(eAccount));
    }

    /**
     * 修改账户信息
     */
    @RequiresPermissions("finance:account:edit")
    @Log(title = "账户信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EAccount eAccount)
    {
        return toAjax(eAccountService.updateEAccount(eAccount));
    }

    /**
     * 删除账户信息
     */
    @RequiresPermissions("finance:account:remove")
    @Log(title = "账户信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(eAccountService.deleteEAccountByIds(ids));
    }

     @RequiresPermissions("finance:account:updateStatus1")
    @PutMapping("/updateStatus1/{id}")
     public AjaxResult updateStatus1(@PathVariable Integer id)
    {
        return toAjax(eAccountService.updateStatus1(id));
    }
    @RequiresPermissions("finance:account:updateStatus2")
    @PutMapping("/updateStatus2/{id}")
    public AjaxResult updateStatus2(@PathVariable Integer id)
    {
        return toAjax(eAccountService.updateStatus2(id));
    }



    @PutMapping("/updateStatusById")
    public AjaxResult updateStatusById(@RequestBody Integer id){
        return toAjax(eAccountService.updateStatusById(id));
    }

    @GetMapping("selectEAccountByPid/{id}")
    public AjaxResult selectEAccountByPid(@PathVariable("id") Integer id){
        return success(eAccountService.selectEAccountByPid(id));
    }
}
